Skip to content

Fix #4867 Union type inference is too eager to widen unions #7829

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

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3c9f377
Fix #8203: handle intersection type in parent registration
liufengyun Feb 5, 2020
3a1f9f6
Fix #7597: Refine checks whether a deferred term member is implemented
odersky Feb 17, 2020
4ae6522
Fix #8333: Check for duplicate symbols in exports
odersky Feb 18, 2020
dc8a4d8
Fix #8355: REPL tests : fix for two tests failing on Windows
michelou Feb 22, 2020
b6737a8
small code change to address review
michelou Feb 22, 2020
f51bf1b
Merge pull request #8356 from michelou/dotty-multiline
smarter Feb 22, 2020
93f65c6
Merge pull request #8332 from dotty-staging/fix-#7597
smarter Feb 22, 2020
811dc19
Merge pull request #8341 from dotty-staging/fix-#8333
smarter Feb 22, 2020
d7ee473
doc(multi-staging): fix typos
robstoll Feb 24, 2020
946604b
doc(multi-staging): more typos
robstoll Feb 24, 2020
c66a33e
Disable Mill libraries
anatoliykmetyuk Feb 20, 2020
5490f95
Fix documentation generation
nicolasstucki Feb 24, 2020
3e68e93
Merge pull request #8351 from lampepfl/anatoliykmetyuk-patch-2
nicolasstucki Feb 24, 2020
e1b2378
Move quote tagging to Staging
nicolasstucki Feb 13, 2020
28c96ad
doc(dep-fun-type): typos
robstoll Feb 24, 2020
082841d
doc(operators): typo and add import to examples
robstoll Feb 24, 2020
57efb73
Merge pull request #8365 from dotty-staging/fix-doc-generation
smarter Feb 25, 2020
0e847de
Merge pull request #8342 from dotty-staging/fix-#8302
nicolasstucki Feb 25, 2020
802ed3b
doc(untupling): fix list at the end, add newline
robstoll Feb 25, 2020
8b5ddf5
doc(context-functions): typo `are` instead of `is`
robstoll Feb 25, 2020
b344239
doc(multi-staging): move setup/flags to create a new project
robstoll Feb 25, 2020
5dcb63a
doc(multi-staging): cleanup new lines
robstoll Feb 25, 2020
8df5b70
doc(macros): fix expansion and some improvements
robstoll Feb 25, 2020
04d5068
Merge pull request #8206 from dotty-staging/fix-8203
liufengyun Feb 25, 2020
4922e7f
doc(operators): wrap one more annotation
robstoll Feb 26, 2020
e829c77
doc(trait param): state which rule is violated
robstoll Feb 26, 2020
91bdeef
doc(creator apply): typos
robstoll Feb 26, 2020
9964ec8
doc(export): add link to note
robstoll Feb 26, 2020
92a3952
Fix lampepfl/dotty-knowledge#30
Uko Feb 26, 2020
764a23e
Merge pull request #8382 from Uko/community-test-rerun
anatoliykmetyuk Feb 26, 2020
d7e0212
Fix lampepfl/dotty-knowledge#17
Uko Feb 26, 2020
6ac98d4
Merge pull request #8384 from Uko/test-sbt-method-annotation
anatoliykmetyuk Feb 26, 2020
0803aff
Fix #8362: Fail compilation if a compile time error can't be inlined …
Uko Feb 26, 2020
b952d41
Avoid overcompilation involving inline or annotation trees
smarter Feb 22, 2020
08f876e
Merge pull request #8359 from dotty-staging/overcompilation-print
smarter Feb 26, 2020
1955f75
Merge pull request #8381 from robstoll/patch-36
smarter Feb 26, 2020
84ea41a
Merge pull request #8387 from Uko/compiletime-error-with-s-interpolator
nicolasstucki Feb 27, 2020
f8e65de
Merge pull request #8374 from robstoll/patch-33
smarter Feb 27, 2020
248009c
Merge pull request #8380 from robstoll/patch-35
smarter Feb 27, 2020
c6f46b5
Merge pull request #8379 from robstoll/patch-34
smarter Feb 27, 2020
8f2aabe
Merge pull request #8363 from robstoll/patch-28
smarter Feb 27, 2020
11bd978
Merge pull request #8372 from robstoll/patch-31
smarter Feb 27, 2020
d943616
Merge pull request #8373 from robstoll/patch-32
smarter Feb 27, 2020
12773ec
revert ascii-doc change
robstoll Feb 27, 2020
5134e98
Merge pull request #8367 from robstoll/patch-30
smarter Feb 27, 2020
63343d2
Merge pull request #8366 from robstoll/patch-29
smarter Feb 27, 2020
1e2506b
Fix exhaustivity issue required to publish bootstrapped
landerlo Dec 12, 2019
2a6e1d0
Fix-#4867 Keep Unions when explicit
landerlo Sep 29, 2019
16288bc
Fix-#4867 Update union tests to improve inference when ascribed
landerlo Sep 30, 2019
735bed5
Fix-#4867 provide positive test for fix
landerlo Dec 20, 2019
bf00a1e
Fix unsafe cast
landerlo Jan 16, 2020
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
Next Next commit
Fix #8203: handle intersection type in parent registration
An enum value may have the type `A & B`, in such cases we
need to register for both `A` and `B`.
  • Loading branch information
liufengyun committed Feb 5, 2020
commit 3c9f377340f0e5665d871fc66cd75286abb3bc66
31 changes: 14 additions & 17 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -901,28 +901,25 @@ class Namer { typer: Typer =>
def registerIfChild(denot: SymDenotation)(implicit ctx: Context): Unit = {
val sym = denot.symbol

def register(child: Symbol, parent: Type) = {
val cls = parent.classSymbol
if (cls.is(Sealed))
if ((child.isInaccessibleChildOf(cls) || child.isAnonymousClass) && !sym.hasAnonymousChild)
addChild(cls, cls)
else if (!cls.is(ChildrenQueried))
addChild(cls, child)
def register(child: Symbol, parentCls: ClassSymbol) = {
if (parentCls.is(Sealed))
if ((child.isInaccessibleChildOf(parentCls) || child.isAnonymousClass) && !sym.hasAnonymousChild)
addChild(parentCls, parentCls)
else if (!parentCls.is(ChildrenQueried))
addChild(parentCls, child)
else
ctx.error(em"""children of $cls were already queried before $sym was discovered.
|As a remedy, you could move $sym on the same nesting level as $cls.""",
ctx.error(em"""children of $parentCls were already queried before $sym was discovered.
|As a remedy, you could move $sym on the same nesting level as $parentCls.""",
child.sourcePos)
}

if (denot.isClass && !sym.isEnumAnonymClass && !sym.isRefinementClass)
denot.asClass.classParents.foreach { parent =>
val child = if (denot.is(Module)) denot.sourceModule else denot.symbol
register(child, parent)
}
else if (denot.is(CaseVal, butNot = Method | Module)) {
if denot.isClass && !sym.isEnumAnonymClass && !sym.isRefinementClass then
val child = if (denot.is(Module)) denot.sourceModule else denot.symbol
denot.asClass.classParents.foreach { parent => register(child, parent.classSymbol.asClass) }
else if denot.is(CaseVal, butNot = Method | Module) then
assert(denot.is(Enum), denot)
register(denot.symbol, denot.info)
}
denot.info.classSymbols.foreach { parent => register(denot.symbol, parent) }
end if
}

/** Intentionally left without `implicit ctx` parameter. We need
Expand Down
19 changes: 19 additions & 0 deletions tests/patmat/i8203.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sealed trait Pretty { self: Color => }
sealed trait Dull { self: Color => }
enum Color {
case Pink extends Color with Pretty
case Red extends Color with Dull
}

def describe(c: Color) = c match {
case Color.Pink => "Amazing!"
case Color.Red => "Yawn..."
}

def describe2(c: Pretty) = c match {
case Color.Pink => "Amazing!"
}

def describe3(c: Dull) = c match {
case Color.Red => "Yawn..."
}