Skip to content

Commit cfc4757

Browse files
committed
fixes petty macro tests
1 parent 27a978a commit cfc4757

File tree

73 files changed

+230
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+230
-196
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,7 +2745,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
27452745
val lencmp = compareLengths(args, formals)
27462746

27472747
def checkNotMacro() = {
2748-
if (fun.symbol != null && fun.symbol.filter(sym => sym != null && sym.isTermMacro) != NoSymbol)
2748+
if (fun.symbol != null && fun.symbol.filter(sym => sym != null && sym.isTermMacro && !sym.isErroneous) != NoSymbol)
27492749
duplErrorTree(NamedAndDefaultArgumentsNotSupportedForMacros(tree, fun))
27502750
}
27512751

@@ -4574,7 +4574,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
45744574
// A: solely for robustness reasons. this mechanism might change in the future, which might break unprotected code
45754575
val expr1 = context.withMacrosDisabled(typed1(expr, mode, pt))
45764576
expr1 match {
4577-
case macroDef if macroDef.symbol.isTermMacro =>
4577+
case macroDef if macroDef.symbol != null && macroDef.symbol.isTermMacro && !macroDef.symbol.isErroneous =>
45784578
MacroEtaError(expr1)
45794579
case _ =>
45804580
typedEta(checkDead(expr1))
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
Macros_Package_10.scala:1: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
2-
package `macro`
1+
macro-deprecate-dont-touch-backquotedidents.scala:37: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
2+
package `macro` {
33
^
4-
Macros_Package_10.scala:3: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
5-
package `macro`.bar
6-
^
7-
Macros_Package_11.scala:3: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
8-
package `macro`.foo
9-
^
10-
Main.scala:2: error: Unmatched closing brace '}' ignored here
11-
}
12-
^
13-
three warnings found
14-
one error found
4+
macro-deprecate-dont-touch-backquotedidents.scala:38: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
5+
package `macro`.bar {
6+
^
7+
macro-deprecate-dont-touch-backquotedidents.scala:43: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
8+
package `macro`.foo {
9+
^
10+
three errors found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xfatal-warnings
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
object Test1 {
2+
val `macro` = ???
3+
}
4+
5+
object Test2 {
6+
var `macro` = ???
7+
}
8+
9+
object Test3 {
10+
type `macro` = Int
11+
}
12+
13+
package test4 {
14+
class `macro`
15+
}
16+
17+
object Test5 {
18+
class `macro`
19+
}
20+
21+
package test6 {
22+
object `macro`
23+
}
24+
25+
object Test7 {
26+
object `macro`
27+
}
28+
29+
package test8 {
30+
trait `macro`
31+
}
32+
33+
object Test9 {
34+
trait `macro`
35+
}
36+
37+
package `macro` {
38+
package `macro`.bar {
39+
}
40+
}
41+
42+
package foo {
43+
package `macro`.foo {
44+
}
45+
}
46+
47+
object Test12 {
48+
val Some(`macro`) = Some(42)
49+
`macro` match {
50+
case `macro` => println(`macro`)
51+
}
52+
}
53+
54+
object Test13 {
55+
def `macro` = 2
56+
}

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Bind_12.scala

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Class_4.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Class_5.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Def_13.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Object_6.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Object_7.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Package_10.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Package_11.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Trait_8.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Trait_9.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Type_3.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Val_1.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Macros_Var_2.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-dont-touch-backquotedidents/Main.scala

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,46 @@
1-
Macros_Bind_12.scala:2: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
2-
val Some(macro) = Some(42)
3-
^
4-
Macros_Bind_12.scala:4: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
5-
case macro => println(macro)
6-
^
7-
Macros_Class_4.scala:3: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
8-
class macro
1+
macro-deprecate-idents.scala:2: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
2+
val macro = ???
93
^
10-
Macros_Class_5.scala:2: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
11-
class macro
12-
^
13-
Macros_Def_13.scala:2: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
14-
def macro = 2
4+
macro-deprecate-idents.scala:6: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
5+
var macro = ???
156
^
16-
Macros_Object_6.scala:3: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
17-
object macro
7+
macro-deprecate-idents.scala:10: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
8+
type macro = Int
189
^
19-
Macros_Object_7.scala:2: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
20-
object macro
21-
^
22-
Macros_Package_10.scala:1: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
23-
package macro
10+
macro-deprecate-idents.scala:14: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
11+
class macro
2412
^
25-
Macros_Package_10.scala:3: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
26-
package macro.bar
13+
macro-deprecate-idents.scala:18: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
14+
class macro
2715
^
28-
Macros_Package_11.scala:3: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
29-
package macro.foo
16+
macro-deprecate-idents.scala:22: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
17+
object macro
18+
^
19+
macro-deprecate-idents.scala:26: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
20+
object macro
21+
^
22+
macro-deprecate-idents.scala:30: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
23+
trait macro
3024
^
31-
Macros_Trait_8.scala:3: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
32-
trait macro
33-
^
34-
Macros_Trait_9.scala:2: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
25+
macro-deprecate-idents.scala:34: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
3526
trait macro
3627
^
37-
Macros_Type_3.scala:2: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
38-
type macro = Int
39-
^
40-
Macros_Val_1.scala:2: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
41-
val macro = ???
42-
^
43-
Macros_Var_2.scala:2: warning: in future versions of Scala "macro" will be a keyword. consider using a different name.
44-
var macro = ???
28+
macro-deprecate-idents.scala:37: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
29+
package macro {
30+
^
31+
macro-deprecate-idents.scala:38: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
32+
package macro.bar {
33+
^
34+
macro-deprecate-idents.scala:43: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
35+
package macro.foo {
36+
^
37+
macro-deprecate-idents.scala:48: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
38+
val Some(macro) = Some(42)
39+
^
40+
macro-deprecate-idents.scala:50: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
41+
case macro => println(macro)
42+
^
43+
macro-deprecate-idents.scala:55: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
44+
def macro = 2
4545
^
46-
Main.scala:2: error: Unmatched closing brace '}' ignored here
47-
}
48-
^
49-
15 warnings found
50-
one error found
46+
15 errors found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xfatal-warnings
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
object Test1 {
2+
val macro = ???
3+
}
4+
5+
object Test2 {
6+
var macro = ???
7+
}
8+
9+
object Test3 {
10+
type macro = Int
11+
}
12+
13+
package test4 {
14+
class macro
15+
}
16+
17+
object Test5 {
18+
class macro
19+
}
20+
21+
package test6 {
22+
object macro
23+
}
24+
25+
object Test7 {
26+
object macro
27+
}
28+
29+
package test8 {
30+
trait macro
31+
}
32+
33+
object Test9 {
34+
trait macro
35+
}
36+
37+
package macro {
38+
package macro.bar {
39+
}
40+
}
41+
42+
package foo {
43+
package macro.foo {
44+
}
45+
}
46+
47+
object Test12 {
48+
val Some(macro) = Some(42)
49+
macro match {
50+
case macro => println(macro)
51+
}
52+
}
53+
54+
object Test13 {
55+
def macro = 2
56+
}

test/files/neg/macro-deprecate-idents/Macros_Def_13.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/files/neg/macro-deprecate-idents/Main.scala

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
macro-keyword-bind.scala:2: error: illegal start of simple pattern
2+
val Some(macro) = Some(42)
3+
^
4+
macro-keyword-bind.scala:6: error: ')' expected but '}' found.
5+
}
6+
^
7+
two errors found
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
macro-keyword-class1.scala:3: error: identifier expected but 'macro' found.
2+
class macro
3+
^
4+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xmacros
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
macro-keyword-class2.scala:2: error: identifier expected but 'macro' found.
2+
class macro
3+
^
4+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xmacros
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
macro-keyword-object1.scala:3: error: identifier expected but 'macro' found.
2+
object macro
3+
^
4+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xmacros
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
macro-keyword-object2.scala:2: error: identifier expected but 'macro' found.
2+
object macro
3+
^
4+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xmacros
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
macro-keyword-package1.scala:1: error: identifier expected but 'macro' found.
2+
package macro
3+
^
4+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xmacros
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
macro-keyword-package2.scala:3: error: identifier expected but 'macro' found.
2+
package macro.foo
3+
^
4+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xmacros
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
macro-keyword-trait1.scala:3: error: identifier expected but 'macro' found.
2+
trait macro
3+
^
4+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xmacros
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
macro-keyword-trait2.scala:2: error: identifier expected but 'macro' found.
2+
trait macro
3+
^
4+
one error found
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xmacros

0 commit comments

Comments
 (0)