Skip to content

Commit dd221ae

Browse files
committed
Address review comments
1 parent d5f5ae5 commit dd221ae

File tree

13 files changed

+43
-8
lines changed

13 files changed

+43
-8
lines changed

compiler/src/dotty/tools/dotc/transform/ElimErasedValueType.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,10 @@ class ElimErasedValueType extends MiniPhase with InfoTransformer { thisPhase =>
9696
(sym1.owner.derivesFrom(defn.PolyFunctionClass) ||
9797
sym2.owner.derivesFrom(defn.PolyFunctionClass))
9898

99-
if (sym1.name != sym2.name &&
100-
!(sym1.name.is(SuperAccessorName) && sym2.name.is(SuperAccessorName))
101-
// super-accessors start as private, and their expanded name can clash after
102-
// erasure. TODO: Verify that this is OK.
103-
||
99+
// super-accessors start as private, and their expanded name can clash after
100+
// erasure. TODO: Verify that this is OK.
101+
def bothSuperAccessors = sym1.name.is(SuperAccessorName) && sym2.name.is(SuperAccessorName)
102+
if (sym1.name != sym2.name && !bothSuperAccessors ||
104103
!info1.matchesLoosely(info2) && !bothPolyApply)
105104
ctx.error(DoubleDefinition(sym1, sym2, root), root.sourcePos)
106105
}

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class CompilationTests extends ParallelTesting {
181181
defaultOptions),
182182
compileFile("tests/neg-custom-args/i6300.scala", allowDeepSubtypes),
183183
compileFile("tests/neg-custom-args/infix.scala", defaultOptions.and("-strict", "-deprecation", "-Xfatal-warnings")),
184-
compileFile("tests/neg-custom-args/alpha.scala", defaultOptions.and("-strict", "-deprecation", "-Xfatal-warnings"))
184+
compileFile("tests/neg-custom-args/missing-alpha.scala", defaultOptions.and("-strict", "-deprecation", "-Xfatal-warnings"))
185185
).checkExpectedErrors()
186186
}
187187

tests/neg/alpha-override/B_1.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Java
2+
public class B_1 extends A_1 {
3+
public int bar() {
4+
return 2;
5+
}
6+
}

tests/neg/alpha-override/C_2.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import annotation.alpha
2+
class C extends B_1 { // error: Name clash between defined and inherited member
3+
@alpha("bar") override def foo(): Int = 3
4+
}

tests/neg/alpha-override/D_3.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import annotation.alpha
2+
class D extends B_1 {
3+
@alpha("bar") def foo(): Int = 3 // error: needs override
4+
}
5+
class E extends B_1 {
6+
@alpha("baz") override def bar(): Int = 3 // error: cannot have an @alpha annotation since external names would be different
7+
}

tests/pos/alpha-override/A_1.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Scala
2+
import annotation.alpha
3+
class A_1 {
4+
@alpha("bar") def foo(): Int = 1
5+
}

tests/pos/alpha-override/B_2.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Java
2+
public class B_2 extends A_1 {
3+
@Override
4+
public int bar() {
5+
return 2;
6+
}
7+
}

tests/pos/alpha.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ object Test {
55
def foo() = 1
66

77
@alpha("bar") def foo(x: Int) = 2
8-
9-
}
8+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/run/alpha.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import annotation.alpha
2+
3+
object Test extends App {
4+
def foo(x: Any): Int = 1
5+
@alpha("bar") def foo[A <: AnyRef](x: A) = 2
6+
7+
assert(foo("a") == 2)
8+
}

0 commit comments

Comments
 (0)