Skip to content

Fix #9780: Tighten condition when to turn superclasses into constructors #9853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ class ExplicitOuter extends MiniPhase with InfoTransformer { thisPhase =>
val parents1 =
for (parent <- impl.parents) yield
val parentCls = parent.tpe.classSymbol.asClass
parent match // ensure class parent is a constructor
parent match
// if we are in a regular class and first parent is also a regular class,
// make sure we have a contructor
case parent: TypeTree
if !parentCls.is(Trait) && !defn.NotRuntimeClasses.contains(parentCls) =>
if !cls.is(Trait) && !parentCls.is(Trait) && !defn.NotRuntimeClasses.contains(parentCls) =>
New(parent.tpe, Nil).withSpan(impl.span)
case _ => parent
cpy.Template(impl)(parents = parents1, body = impl.body ++ newDefs)
Expand Down
18 changes: 18 additions & 0 deletions tests/pos/i9780.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import java.awt.event.WindowEvent
import java.awt.{Window => AWTWindow}

abstract class Window {
def peer: AWTWindow with InterfaceMixin

protected trait InterfaceMixin extends javax.swing.RootPaneContainer

protected trait SuperMixin extends java.awt.Window {
override protected def processWindowEvent(e: WindowEvent): Unit = {
super.processWindowEvent(e)
if (e.getID == WindowEvent.WINDOW_CLOSING)
closeOperation()
}
}

def closeOperation(): Unit = ()
}