Skip to content
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

Possible regression in type inference #15652

Closed
griggt opened this issue Jul 12, 2022 · 3 comments · Fixed by #15667
Closed

Possible regression in type inference #15652

griggt opened this issue Jul 12, 2022 · 3 comments · Fixed by #15667
Assignees
Milestone

Comments

@griggt
Copy link
Contributor

griggt commented Jul 12, 2022

This is a reproducer for the community build failure of h8io/borscht reported in #15647

Compiler version

3.2.0-RC2
Works in 3.1.3

Minimized code

trait Node
type NodeParser[T] = Node => T

def child(key: String): Option[Node] = ???

def optionalOneOf[T](in: Map[String, NodeParser[? <: T]]): Option[T] =
  val mappings = in flatMap { (key, parser) =>
    child(key) map { node =>
      key -> (() => parser(node))
    }
  }
  mappings.headOption map (_._2())

Output

-- [E007] Type Mismatch Error: borscht.scala:12:31 -----------------------------
12 |  mappings.headOption map (_._2())
   |                           ^^^^^^
   |                           Found:    Any
   |                           Required: T
   |
   | longer explanation available when compiling with `-explain`
1 error found
@odersky
Copy link
Contributor

odersky commented Jul 12, 2022

Can we find out what commit caused this?

@odersky odersky assigned bishabosha and unassigned odersky Jul 12, 2022
@bishabosha bishabosha assigned griggt and unassigned bishabosha Jul 12, 2022
@griggt
Copy link
Contributor Author

griggt commented Jul 12, 2022

First bad commit is 0a95a3d from #14816

@griggt griggt assigned odersky and unassigned griggt Jul 12, 2022
@odersky
Copy link
Contributor

odersky commented Jul 12, 2022

Workaround:

def optionalOneOf[T](in: Map[String, NodeParser[T]]): Option[T]

This is really what it should have been all along.

@mbovel mbovel added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 12, 2022
odersky added a commit to dotty-staging/dotty that referenced this issue Jul 13, 2022
We sometimes create a dependent parameter reference p.X where
`p` is a path with a type that has a wildcard argument, e.g. `P[X >: L <: H].`
So far the denotation of `p.X` had as info the bounds with which `X` was
declared in `P`. Now it gets the actual parameter bounds instead.

Fixes scala#15652

scala#15652 started failing when tuple unpackings started to use `val`s instead of `def`s
in scala#14816. That caused dependent class parameter references to be created and uncovered
the problem.
Kordyjan pushed a commit to dotty-staging/dotty that referenced this issue Jul 26, 2022
We sometimes create a dependent parameter reference p.X where
`p` is a path with a type that has a wildcard argument, e.g. `P[X >: L <: H].`
So far the denotation of `p.X` had as info the bounds with which `X` was
declared in `P`. Now it gets the actual parameter bounds instead.

Fixes scala#15652

scala#15652 started failing when tuple unpackings started to use `val`s instead of `def`s
in scala#14816. That caused dependent class parameter references to be created and uncovered
the problem.
Kordyjan pushed a commit to dotty-staging/dotty that referenced this issue Jul 26, 2022
We sometimes create a dependent parameter reference p.X where
`p` is a path with a type that has a wildcard argument, e.g. `P[X >: L <: H].`
So far the denotation of `p.X` had as info the bounds with which `X` was
declared in `P`. Now it gets the actual parameter bounds instead.

Fixes scala#15652

scala#15652 started failing when tuple unpackings started to use `val`s instead of `def`s
in scala#14816. That caused dependent class parameter references to be created and uncovered
the problem.
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
We sometimes create a dependent parameter reference p.X where
`p` is a path with a type that has a wildcard argument, e.g. `P[X >: L <: H].`
So far the denotation of `p.X` had as info the bounds with which `X` was
declared in `P`. Now it gets the actual parameter bounds instead.

Fixes scala#15652

scala#15652 started failing when tuple unpackings started to use `val`s instead of `def`s
in scala#14816. That caused dependent class parameter references to be created and uncovered
the problem.
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants