Skip to content

Commit 5887fab

Browse files
committed
Don't infer final classes as parents for anonymous new
Needed to make run/t6154.scala compile.
1 parent 00c51d5 commit 5887fab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
444444
case templ: untpd.Template =>
445445
import untpd._
446446
var templ1 = templ
447+
def isEligible(tp: Type) = tp.exists && !tp.typeSymbol.is(Final)
447448
if (templ1.parents.isEmpty &&
448449
isFullyDefined(pt, ForceDegree.noBottom) &&
449-
pt.underlyingClassRef(refinementOK = false).exists)
450+
isEligible(pt.underlyingClassRef(refinementOK = false)))
450451
templ1 = cpy.Template(templ)(parents = untpd.TypeTree(pt) :: Nil)
451452
templ1.parents foreach {
452453
case parent: RefTree =>

0 commit comments

Comments
 (0)