--* From postmaster%watson.vnet.ibm.com@yktvmv.watson.ibm.com  Fri Jun 24 11:26:48 1994
--* Received: from yktvmv-ob.watson.ibm.com by asharp.watson.ibm.com (AIX 3.2/UCB 5.64/930311)
--*           id AA26477; Fri, 24 Jun 1994 11:26:48 -0400
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 2473; Fri, 24 Jun 94 11:26:48 EDT
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.BRONSTEI.NOTE.YKTVMV.9599.Jun.24.11:10:17.-0400>
--*           for asbugs@watson; Fri, 24 Jun 94 11:26:47 -0400
--* Received: from inf.ethz.ch by watson.ibm.com (IBM VM SMTP V2R3) with TCP;
--*    Fri, 24 Jun 94 11:10:17 EDT
--* Received: from ru7.inf.ethz.ch (ru7.inf.ethz.ch [129.132.12.16]) by inf.ethz.ch (8.6.8/8.6.6) with ESMTP id RAA06377 for <asbugs@watson.ibm.com>; Fri, 24 Jun 1994 17:10:07 +0200
--* From: Manuel Bronstein <bronstei@inf.ethz.ch>
--* Received: (bronstei@localhost) by ru7.inf.ethz.ch (8.6.8/8.6.6) id RAA13288 for asbugs@watson.ibm.com; Fri, 24 Jun 1994 17:10:06 +0200
--* Date: Fri, 24 Jun 1994 17:10:06 +0200
--* Message-Id: <199406241510.RAA13288@ru7.inf.ethz.ch>
--* To: asbugs@watson.ibm.com
--* Subject: [4] the compiler finds 2 equal meanings for a name! [nil.as][0.35.0]

--@ Fixed  by:  SSD   Mon May 15 12:05:42 EDT 1995 
--@ Tested by:  none 
--@ Summary:    Undetermined type inference fixes now disambiguate the meanings for nil?. 

---------------------------------- nil.as --------------------------------
--
-- ru7.inf.ethz.ch{bronstei} 167: asharp -M2 nil.as
-- "nil.as", line 17:                         nil? p => error "nil pointer";
--                    ........................^
-- [L17 C25] (Error) 2 meanings for `nil?' in this context.
-- The possible types were:
--           nil?: (p: %) -> Boolean, a local
--           nil?: (p: %) -> Boolean, a local
--   The context requires an expression of type (p: %) -> Boolean.
--

#include "aslib.as"

MyPointer(T:Type): with { nil?: % -> Boolean } == add {
	macro Rep == P;
	macro R == Record(val:T);

	-- untagged union of Record and Nil
	P: with {
		nil?:    % -> Boolean;
		deref:   % -> R;
	} == add {
		macro Rep == Pointer;
		import from Rep;
		nil?(p: %):Boolean == nil? rep p;

		deref(p:%):R == {
			nil? p => error "nil pointer";
			p pretend R;
		}
	}
	import from Rep;
	nil?(p:%):Boolean == nil? rep p;
}

 
