Skip to content

Fix #5036: Add missing implementation for setters of Unit #5845

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
Feb 6, 2019
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
13 changes: 6 additions & 7 deletions compiler/src/dotty/tools/dotc/transform/Memoize.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,12 @@ class Memoize extends MiniPhase with IdentityDenotTransformer { thisPhase =>
} else if (sym.isSetter) {
if (!sym.is(ParamAccessor)) { val Literal(Constant(())) = tree.rhs } // This is intended as an assertion
field.setFlag(Mutable) // Necessary for vals mixed in from Scala2 traits
if (isErasableBottomField(tree.vparamss.head.head.tpt.tpe.classSymbol)) tree
else {
val initializer = Assign(ref(field), adaptToField(ref(tree.vparamss.head.head.symbol)))
val setterDef = cpy.DefDef(tree)(rhs = transformFollowingDeep(initializer)(ctx.withOwner(sym)))
removeAnnotations(sym)
setterDef
}
val initializer =
if (isErasableBottomField(tree.vparamss.head.head.tpt.tpe.classSymbol)) Literal(Constant(()))
else Assign(ref(field), adaptToField(ref(tree.vparamss.head.head.symbol)))
val setterDef = cpy.DefDef(tree)(rhs = transformFollowingDeep(initializer)(ctx.withOwner(sym)))
removeAnnotations(sym)
setterDef
}
else tree // curiously, some accessors from Scala2 have ' ' suffixes. They count as
// neither getters nor setters
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i5036.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class i0(var i1: Unit)
class i1(var i1: Null)
class i3(var i1: Nothing)