Skip to content

value classes lose type parameter bounds #6482

Closed

Description

@scabug

The following class compiles without "extends AnyVal", but with it:

final class TraversableOnceOps[+A](val collection: TraversableOnce[A]) extends AnyVal {
  def reduceLeftOption[B >: A](op: (B, A) => B): Option[B] =
    if (collection.isEmpty) None else Some(collection.reduceLeft[B](op))
}
// error: type arguments [B] do not conform to method reduceLeft's type parameter bounds [B >: A]
//            if (collection.isEmpty) None else Some(collection.reduceLeft[B](op))
//                                                                        ^

This is similar to #6034 and will be fixed in the same spot, with more attention to the handling of method type parameters when synthesizing the extension methods.

Activity

  1. scabug commented on Oct 6, 2012

    @scabug
    Author
  2. scabug commented on Oct 6, 2012

    @scabug
    Author

    @paulp said:
    Fix pending.

  3. scabug commented on Oct 8, 2012

    @scabug
    Author
  4. scabug commented on Jan 9, 2013

    @scabug
    Author

    @retronym said:
    Fixed by: scala/scala#1468

  5. scabug commented on Jan 22, 2013

    @scabug
    Author

    @adriaanm said:
    reopening for 2.10.1-RC1 backport

  6. scabug commented on Jan 26, 2013

    @scabug
    Author
  7. added this to the 2.10.1 milestone on Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions