|
Revision 3550, 1.2 KB
(checked in by sukyoungryu, 9 months ago)
|
|
[copyright] Fixed the copyright notices.
|
| Line | |
|---|
| 1 | (******************************************************************************* |
|---|
| 2 | Copyright 2009 Sun Microsystems, Inc., |
|---|
| 3 | 4150 Network Circle, Santa Clara, California 95054, U.S.A. |
|---|
| 4 | All rights reserved. |
|---|
| 5 | |
|---|
| 6 | U.S. Government Rights - Commercial software. |
|---|
| 7 | Government users are subject to the Sun Microsystems, Inc. standard |
|---|
| 8 | license agreement and applicable provisions of the FAR and its supplements. |
|---|
| 9 | |
|---|
| 10 | Use is subject to license terms. |
|---|
| 11 | |
|---|
| 12 | This distribution may include materials developed by third parties. |
|---|
| 13 | |
|---|
| 14 | Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered |
|---|
| 15 | trademarks of Sun Microsystems, Inc. in the U.S. and other countries. |
|---|
| 16 | ******************************************************************************) |
|---|
| 17 | |
|---|
| 18 | component GenericOverload4 |
|---|
| 19 | export Executable |
|---|
| 20 | |
|---|
| 21 | (* Should not compile *) |
|---|
| 22 | |
|---|
| 23 | (* This demonstrates why it is not correct to |
|---|
| 24 | substitute bounds for generic type parameters |
|---|
| 25 | when checking correctness of overloading. *) |
|---|
| 26 | |
|---|
| 27 | trait B end |
|---|
| 28 | object b extends B end |
|---|
| 29 | object A extends B end |
|---|
| 30 | |
|---|
| 31 | f[\ U, V \] ( u:U, v:V, b:B) = 1 |
|---|
| 32 | f[\ U, V \] ( u:U, v:V, a:A) = 2 |
|---|
| 33 | |
|---|
| 34 | run():() = do |
|---|
| 35 | |
|---|
| 36 | x = 1 |
|---|
| 37 | |
|---|
| 38 | print(x " ") |
|---|
| 39 | println(x) |
|---|
| 40 | |
|---|
| 41 | g = f[\A, B\] |
|---|
| 42 | println(g(A, b, b)) |
|---|
| 43 | println(g(A, b, A)) |
|---|
| 44 | |
|---|
| 45 | println(f(A, b, b)) |
|---|
| 46 | println(f(A, b, A)) |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | end |
|---|
| 50 | |
|---|
| 51 | end |
|---|