Skip to content

Commit 85d1322

Browse files
Merge pull request #9853 from dotty-staging/fix-#9780
Fix #9780: Tighten condition when to turn superclasses into constructors
2 parents af1b4a0 + dce0d5e commit 85d1322

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ class ExplicitOuter extends MiniPhase with InfoTransformer { thisPhase =>
101101
val parents1 =
102102
for (parent <- impl.parents) yield
103103
val parentCls = parent.tpe.classSymbol.asClass
104-
parent match // ensure class parent is a constructor
104+
parent match
105+
// if we are in a regular class and first parent is also a regular class,
106+
// make sure we have a contructor
105107
case parent: TypeTree
106-
if !parentCls.is(Trait) && !defn.NotRuntimeClasses.contains(parentCls) =>
108+
if !cls.is(Trait) && !parentCls.is(Trait) && !defn.NotRuntimeClasses.contains(parentCls) =>
107109
New(parent.tpe, Nil).withSpan(impl.span)
108110
case _ => parent
109111
cpy.Template(impl)(parents = parents1, body = impl.body ++ newDefs)

tests/pos/i9780.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.awt.event.WindowEvent
2+
import java.awt.{Window => AWTWindow}
3+
4+
abstract class Window {
5+
def peer: AWTWindow with InterfaceMixin
6+
7+
protected trait InterfaceMixin extends javax.swing.RootPaneContainer
8+
9+
protected trait SuperMixin extends java.awt.Window {
10+
override protected def processWindowEvent(e: WindowEvent): Unit = {
11+
super.processWindowEvent(e)
12+
if (e.getID == WindowEvent.WINDOW_CLOSING)
13+
closeOperation()
14+
}
15+
}
16+
17+
def closeOperation(): Unit = ()
18+
}

0 commit comments

Comments
 (0)