Skip to content

Commit 0d4ca15

Browse files
committed
Make constructors effectively final
This is mainly a cleanup.
1 parent a1d22d2 commit 0d4ca15

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ object SymDenotations {
11961196
isOneOf(EffectivelyFinalFlags)
11971197
|| is(Inline, butNot = Deferred)
11981198
|| is(JavaDefinedVal, butNot = Method)
1199+
|| isConstructor
11991200
|| !owner.isExtensibleClass
12001201

12011202
/** A class is effectively sealed if has the `final` or `sealed` modifier, or it

compiler/src/dotty/tools/dotc/transform/init/Util.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,9 @@ object Util:
7575
case _ =>
7676
None
7777

78-
def resolve(cls: ClassSymbol, sym: Symbol)(using Context): Symbol = log("resove " + cls + ", " + sym, printer, (_: Symbol).show) {
79-
if (sym.isEffectivelyFinal || sym.isConstructor) sym
78+
def resolve(cls: ClassSymbol, sym: Symbol)(using Context): Symbol = log("resove " + cls + ", " + sym, printer, (_: Symbol).show):
79+
if sym.isEffectivelyFinal then sym
8080
else sym.matchingMember(cls.appliedRef)
81-
}
82-
8381

8482
extension (sym: Symbol)
8583
def hasSource(using Context): Boolean = !sym.defTree.isEmpty

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ class RefChecks extends MiniPhase { thisPhase =>
17061706
// if (settings.warnNullaryUnit)
17071707
// checkNullaryMethodReturnType(sym)
17081708
// if (settings.warnInaccessible) {
1709-
// if (!sym.isConstructor && !sym.isEffectivelyFinal && !sym.isSynthetic)
1709+
// if (!sym.isEffectivelyFinal && !sym.isSynthetic)
17101710
// checkAccessibilityOfReferencedTypes(tree)
17111711
// }
17121712
// tree match {

0 commit comments

Comments
 (0)