Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable range positions (-Yrangepos) by default #9146

Merged
merged 1 commit into from Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Expand Up @@ -251,7 +251,7 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
val Ydumpclasses = StringSetting ("-Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "")
val stopAfter = PhasesSetting ("-Ystop-after", "Stop after") withAbbreviation ("-stop") // backward compat
val stopBefore = PhasesSetting ("-Ystop-before", "Stop before")
val Yrangepos = BooleanSetting ("-Yrangepos", "Use range positions for syntax trees.")
val Yrangepos = BooleanSetting ("-Yrangepos", "Use range positions for syntax trees.", true)
val Yvalidatepos = PhasesSetting ("-Yvalidate-pos", s"Validate positions after the given phases (implies ${Yrangepos.name})") withPostSetHook (_ => Yrangepos.value = true)
val Yreifycopypaste = BooleanSetting ("-Yreify-copypaste", "Dump the reified trees in copypasteable representation.")
val Ymacroexpand = ChoiceSetting ("-Ymacro-expand", "policy", "Control expansion of macros, useful for scaladoc and presentation compiler.", List(MacroExpand.Normal, MacroExpand.None, MacroExpand.Discard), MacroExpand.Normal)
Expand Down
2 changes: 1 addition & 1 deletion src/reflect/scala/reflect/runtime/Settings.scala
Expand Up @@ -46,7 +46,7 @@ private[reflect] class Settings extends MutableSettings {
val XnoPatmatAnalysis = new BooleanSetting(false)
val Xprintpos = new BooleanSetting(false)
val Yposdebug = new BooleanSetting(false)
val Yrangepos = new BooleanSetting(false)
val Yrangepos = new BooleanSetting(true)
val Yshowsymowners = new BooleanSetting(false)
val Yshowsymkinds = new BooleanSetting(false)
val breakCycles = new BooleanSetting(false)
Expand Down
20 changes: 10 additions & 10 deletions test/files/run/StubErrorTypeDef.check
@@ -1,18 +1,18 @@
error: newSource1.scala:4: incompatible type in overriding
type D <: stuberrors.A (defined in class B);
found : stuberrors.E
required: <: stuberrors.A
error: newSource1.scala:4: Symbol 'type stuberrors.A' is missing from the classpath.
This symbol is required by 'class stuberrors.E'.
Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'E.class' was compiled against an incompatible version of stuberrors.
new B { type D = E }
^
^
error: newSource1.scala:4: Symbol 'type stuberrors.A' is missing from the classpath.
This symbol is required by 'type stuberrors.B.D'.
Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'B.class' was compiled against an incompatible version of stuberrors.
new B { type D = E }
^
error: newSource1.scala:4: Symbol 'type stuberrors.A' is missing from the classpath.
This symbol is required by 'class stuberrors.E'.
Make sure that type A is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'E.class' was compiled against an incompatible version of stuberrors.
error: newSource1.scala:4: incompatible type in overriding
type D <: stuberrors.A (defined in class B);
found : stuberrors.E
required: <: stuberrors.A
new B { type D = E }
^
^
2 changes: 1 addition & 1 deletion test/files/run/macro-rangepos-args.check
@@ -1 +1 @@
Line: 3. Width: 1.
Line: 3. Width: 5.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

88 changes: 44 additions & 44 deletions test/files/run/sd187.check
@@ -1,23 +1,23 @@
[[syntax trees at end of patmat]] // newSource1.scala
[7]package [7]<empty> {
[7]class C extends [9][2302]scala.AnyRef {
[1:2302]package [1:1]<empty> {
[1:2302]class C extends [9:2302][2302]scala.AnyRef {
[2302]def <init>(): [9]C = [2302]{
[2302][2302][2302]C.super.<init>();
[9]()
};
[107]def commonSubPattern([124]x: [127]<type: [127]scala.Any>): [107]AnyVal = [205]{
[205]<synthetic> var rc6: [205]Boolean = [205]false;
[205]<synthetic> <stable> var x3: [205]String = [205][205][205]null.asInstanceOf[[205]String];
[205]{
[205]case <synthetic> val x1: [205]Any = [205]x;
[205]case8(){
[313]if ([313][313]x1.isInstanceOf[[313]Option[_]])
[325][325]matchEnd7([325]())
[103:904]def commonSubPattern([124:130]x: [127:130]<type: [127:130]scala.Any>): [107]AnyVal = [205:206]{
[205:206]<synthetic> var rc6: [205]Boolean = [205]false;
[205:206]<synthetic> <stable> var x3: [205]String = [205][205][205]null.asInstanceOf[[205]String];
[205:206]{
[205:206]case <synthetic> val x1: [205]Any = [205:206]x;
[205:206]case8(){
[312:324]if ([313][313]x1.isInstanceOf[[313]Option[_]])
[325:327][325]matchEnd7([325:327]())
else
[313][313]case9()
};
[205]case9(){
[412]if ([412][412]x1.isInstanceOf[[412]String])
[205:206]case9(){
[412:421]if ([412][412]x1.isInstanceOf[[412]String])
[412]{
[412][412]rc6 = [412]true;
[412][412]x3 = [412]([412][412]x1.asInstanceOf[[412]String]: [412]String);
Expand All @@ -29,32 +29,32 @@
else
[412][412]case10()
};
[205]case10(){
[612]if ([612][612]rc6.&&([627][627]x3.==([630]"6")))
[205:206]case10(){
[612:621]if ([612][612]rc6.&&([627][627]x3.==([630]"6")))
[712][712]matchEnd7([712][712]x3.hashCode())
else
[612][612]case11()
};
[205]case11(){
[205][205]matchEnd7([205]throw [205][205][205]new [205]MatchError([205]x1))
[205:206]case11(){
[205:206][205:206]matchEnd7([205:206]throw [205:206][205:206][205:206]new [205:206]MatchError([205:206]x1))
};
[205]matchEnd7(x: [NoPosition]AnyVal){
[205]x
[205:206]matchEnd7(x: [NoPosition]AnyVal){
[205:206]x
}
}
};
[1007]def extractor([1017]x: [1020]<type: [1020]scala.Any>): [1007]Any = [1027]{
[1027]case <synthetic> val x1: [1027]Any = [1027]x;
[1027]case6(){
[1120]if ([1120][1120]x1.isInstanceOf[[1120]Product2[T1,T2]])
[1120]{
[1120]<synthetic> val x2: [1120]Product2[T1,T2] = [1120]([1120][1120]x1.asInstanceOf[[1120]Product2[T1,T2]]: [1120]Product2[T1,T2]);
[1112]{
[1112]<synthetic> val o8: [1112]Option[Product2[T1,T2]] = [1112][1112][1112]scala.Product2.unapply[[1112]T1, [1112]T2]([1112]x2);
[1112]if ([1112]o8.isEmpty.unary_!)
[1112]{
[1121]val a: [1121]Any = [1121]o8.get._1;
[1210][1210]matchEnd5([1210]a)
[1003:1306]def extractor([1017:1023]x: [1020:1023]<type: [1020:1023]scala.Any>): [1007]Any = [1027:1028]{
[1027:1028]case <synthetic> val x1: [1027]Any = [1027:1028]x;
[1027:1028]case6(){
[1112:1126]if ([1120][1120]x1.isInstanceOf[[1120]Product2[T1,T2]])
[1112:1126]{
[1112:1126]<synthetic> val x2: [1120]Product2[T1,T2] = [1120]([1120][1120]x1.asInstanceOf[[1120]Product2[T1,T2]]: [1120]Product2[T1,T2]);
[1112:1120]{
[1112:1120]<synthetic> val o8: [1112]Option[Product2[T1,T2]] = [1112:1120][1112:1120][1112:1120]scala.Product2.unapply[[1112]T1, [1112]T2]([1112]x2);
[1121:1211]if ([1112]o8.isEmpty.unary_!)
[1121:1211]{
[1121:1122]val a: [1121]Any = [1121]o8.get._1;
[1210:1211][1210]matchEnd5([1210:1211]a)
}
else
[1112][1112]case7()
Expand All @@ -63,24 +63,24 @@
else
[1120][1120]case7()
};
[1027]case7(){
[1027][1027]matchEnd5([1027]throw [1027][1027][1027]new [1027]MatchError([1027]x1))
[1027:1028]case7(){
[1027:1028][1027:1028]matchEnd5([1027:1028]throw [1027:1028][1027:1028][1027:1028]new [1027:1028]MatchError([1027:1028]x1))
};
[1027]matchEnd5(x: [NoPosition]Any){
[1027]x
[1027:1028]matchEnd5(x: [NoPosition]Any){
[1027:1028]x
}
};
[1407]def swatch: [1407]String = [1505]try {
[1607][1607][1607]C.this.toString()
[1403:2204]def swatch: [1407]String = [1505:2106]try {
[1607:1615][1607:1615][1607]C.this.toString()
} catch {
[1505]case [1505](ex6 @ [1505]_) => [1505]{
[1812]<synthetic> val x4: [1812]Throwable = [1812]ex6;
[1505]case9(){
[1812]if ([1812][1812]x4.ne([1812]null))
[1812]{
[1812]<synthetic> val x5: [1812]Throwable = [1812]x4;
[1812]if ([1915][1915][1912]"".isEmpty())
[2014][2014]matchEnd8([2014][2014]x5.toString())
[1505:2106]case [1505](ex6 @ [1505]_) => [1812:1824]{
[1812:1824]<synthetic> val x4: [1812]Throwable = [1812]ex6;
[1812:1824]case9(){
[1812:1824]if ([1812][1812]x4.ne([1812]null))
[1812:2022]{
[1812:1824]<synthetic> val x5: [1812]Throwable = [1812]x4;
[1912:2022]if ([1912:1922][1912:1922][1912:1914]"".isEmpty())
[2012:2022][2014]matchEnd8([2014][2014]x5.toString())
else
[1812][1812]case10()
}
Expand Down
52 changes: 26 additions & 26 deletions test/files/run/string-switch-pos.check
@@ -1,63 +1,63 @@
[[syntax trees at end of patmat]] // newSource1.scala
[6]package [6]<empty> {
[6]class Switch extends [13][187]scala.AnyRef {
[0:187]package [0:0]<empty> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That [0:0] looks wrong... but doesn't seem to affect anything.

[0:187]class Switch extends [13:187][187]scala.AnyRef {
[187]def <init>(): [13]Switch = [187]{
[187][187][187]Switch.super.<init>();
[13]()
};
[21]def switch([28]s: [31]<type: [31]scala.Predef.String>, [39]cond: [45]<type: [45]scala.Boolean>): [21]Int = [56]{
[56]case <synthetic> val x1: [56]String = [56]s;
[56][56]x1 match {
[56]case [75]"AaAa" => [93]1
[56]case [104]"asdf" => [122]2
[133]case [133]"BbBb" => [133]if ([143]cond)
[151]3
[17:185]def switch([28:37]s: [31:37]<type: [31:37]scala.Predef.String>, [39:52]cond: [45:52]<type: [45:52]scala.Boolean>): [21]Int = [56:57]{
[56:57]case <synthetic> val x1: [56]String = [56:57]s;
[56:57][56:57]x1 match {
[56:57]case [75:81]"AaAa" => [93:94]1
[56:57]case [104:110]"asdf" => [122:123]2
[133:139]case [133:139]"BbBb" => [143:181]if ([143:147]cond)
[151:152]3
else
[180]4
[56]case [56]_ => [56]throw [56][56][56]new [56]MatchError([56]x1)
[180:181]4
[56:57]case [56:57]_ => [56:57]throw [56:57][56:57][56:57]new [56:57]MatchError([56:57]x1)
}
}
}
}

[[syntax trees at end of cleanup]] // newSource1.scala
[6]package [6]<empty> {
[6]class Switch extends [13][13]Object {
[21]def switch([28]s: [31]<type: [31]scala.Predef.String>, [39]cond: [45]<type: [45]scala.Boolean>): [21]Int = [56]{
[56]case <synthetic> val x1: [56]String = [56]s;
[56]{
[56][56]if ([56][56]x1.eq([56]null))
[0:187]package [0:0]<empty> {
[0:187]class Switch extends [13:187][13:187]Object {
[17:185]def switch([28:37]s: [31:37]<type: [31:37]scala.Predef.String>, [39:52]cond: [45:52]<type: [45:52]scala.Boolean>): [21]Int = [56:57]{
[56:57]case <synthetic> val x1: [56]String = [56:57]s;
[56:57]{
[56:139][56:57]if ([56][56]x1.eq([56]null))
[56]0
else
[56][56]x1.hashCode() match {
[56]case [56]2031744 => [75]if ([75][75][75]"AaAa".equals([75]x1))
[75:81]case [56]2031744 => [75:81]if ([75][75][75]"AaAa".equals([75]x1))
[75][75]case1()
else
[56][56]matchEnd2()
[56]case [56]2062528 => [133]if ([133][133][133]"BbBb".equals([133]x1))
[133:139]case [56]2062528 => [133:139]if ([133][133][133]"BbBb".equals([133]x1))
[133][133]case3()
else
[56][56]matchEnd2()
[56]case [56]3003444 => [104]if ([104][104][104]"asdf".equals([104]x1))
[104:110]case [56]3003444 => [104:110]if ([104][104][104]"asdf".equals([104]x1))
[104][104]case2()
else
[56][56]matchEnd2()
[56]case [56]_ => [56][56]matchEnd2()
};
[56]case1(){
[56][56]matchEnd1([93]1)
[56][56]matchEnd1([93:94]1)
};
[56]case2(){
[56][56]matchEnd1([122]2)
[56][56]matchEnd1([122:123]2)
};
[56]case3(){
[56][56]matchEnd1([133]if ([143]cond)
[151]3
[56][56]matchEnd1([143:181]if ([143:147]cond)
[151:152]3
else
[180]4)
[180:181]4)
};
[56]matchEnd2(){
[56][56]matchEnd1([56]throw [56][56][56]new [56]MatchError([56]x1))
[56][56]matchEnd1([56:57]throw [56:57][56:57][56:57]new [56:57]MatchError([56:57]x1))
};
[56]matchEnd1(x$1: [NoPosition]Int){
[56]x$1
Expand Down