Description
This section indicates that when C<T>
is a type literal, C<T>.toString
and C<T>.toString()
is a constructor tearoff respectively a constructor invocation, which causes a compile-time error when C
does not have a constructor named C.toString
.
This is consistent with a very old rule: C.toString()
is an error when C
does not have a static member named toString
, and if we want to call the Object
instance method we need to use (C).toString()
.
However, when f
denotes a function declaration we have a similar constructs f<T>.toString
and f<T>.toString()
. In this case there is no interpretation of the term which involves a constructor (tearoff or invocation), and hence it seems odd that we would insist that it is an operation that involves a constructor, and then report an error when there is no constructor named f.toString
.
Hence, it seems reasonable that we should
- Accept terms like
f<T>.toString
andf<T>.toString()
, and consider them to be a tearoff / an invocation of the instance membertoString
. Note that this may be useful, because we might also have some applicable extension methods. - Declare that such terms are a compile-time error (we can write
(f<T>).toString()
), but report an error which is more meaningful than "there is no such constructor".
WDYT, @munificent, @JakeMac, @lrhn, @leafpetersen, @natebosch, @stereotype441?
PS: Unblock dart-lang/sdk#46887 when this issue has been resolved.