Skip to content

Commit 6317000

Browse files
authored
Merge pull request #5174 from dotty-staging/dynamic
Don't report Dynamic inheritance warning on Dynamic itself
2 parents 5b91393 + 3c6ebee commit 6317000

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,13 @@ class Typer extends Namer
16031603
}
16041604
val cdef1 = assignType(cpy.TypeDef(cdef)(name, impl1), cls)
16051605
checkVariance(cdef1)
1606-
if (ctx.phase.isTyper && cdef1.tpe.derivesFrom(defn.DynamicClass) && !ctx.dynamicsEnabled) {
1606+
1607+
val reportDynamicInheritance =
1608+
ctx.phase.isTyper &&
1609+
cdef1.symbol.ne(defn.DynamicClass) &&
1610+
cdef1.tpe.derivesFrom(defn.DynamicClass) &&
1611+
!ctx.dynamicsEnabled
1612+
if (reportDynamicInheritance) {
16071613
val isRequired = parents1.exists(_.tpe.isRef(defn.DynamicClass))
16081614
ctx.featureWarning(nme.dynamics.toString, "extension of type scala.Dynamic", isScala2Feature = true,
16091615
cls, isRequired, cdef.pos)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CompilationTests extends ParallelTesting {
4848
compileFile("tests/pos-special/completeFromSource/Test2.scala", defaultOptions.and("-sourcepath", "tests/pos-special")) +
4949
compileFile("tests/pos-special/completeFromSource/Test3.scala", defaultOptions.and("-sourcepath", "tests/pos-special", "-scansource")) +
5050
compileFile("tests/pos-special/completeFromSource/nested/Test4.scala", defaultOptions.and("-sourcepath", "tests/pos-special", "-scansource")) +
51-
compileFilesInDir("tests/pos-special/fatal-warnings", defaultOptions.and("-Xfatal-warnings")) +
51+
compileFilesInDir("tests/pos-special/fatal-warnings", defaultOptions.and("-Xfatal-warnings", "-feature")) +
5252
compileList(
5353
"compileMixed",
5454
List(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package scala
2+
3+
trait Dynamic extends Any

0 commit comments

Comments
 (0)